<?php
	
	namespace Admin\Model;
	use Think\Model;

	class FriendlinkModel extends Model{

		//友情链接展示
		public function linkshow(){
			$data = $this->select();
			$status = ['禁用' , '启用'];
			foreach ($data as $key => &$value) {
				$value['addtime'] = date('Y-m-d' , $value['addtime']);
				$value['status'] = $status[$value['status']];
			}
			return $data;
		}

		//友情链接添加
		public function increaseshow(){
			$post = I('post.');
			$post['addtime'] = time();
			$res = $this->add($post);
			return $res;
		}

		// 友情链接修改
		public function modify(){
			
			$post = I('post.');
			$post['linkname'] = &strip_tags($post['linkname']);
			$id = $post['id'];
			unset($post['id']);

			$res = $this->where('id = '.$id)->save($post);
			return $res;
		}

		// 友情链接修改状态
		public function status(){
			$get = I('get.');
			$id = $get['id'];
			$status = $get['status'];
			if ($status == '禁用') {
				$status = 1;
			}else{
				$status = 0;
			}
			$data['status'] = $status;

			$res = $this->where('id = ' . $id)->save($data);
			return $res;
		}





	}
